import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		//tabbar:[],
		//tabbarTextColor:'',
		//tabbarTextActiveColor:"",
		showLoading:false,
		uerInfo: {},
		token:'',
		hasLogin: false,
	},
	mutations: {
		//SET_COLOR(state,colors){
			// 底部菜单文字 选中
		//	state.tabbarTextActiveColor = colors.tabbarTextActiveColor
			// 底部菜单文字 未选中
		//	state.tabbarTextColor = colors.tabbarTextColor
		//},
		
		//SET_TABBAR(state,tabbar){
		//	state.tabbar = tabbar||[]
		//},
		// 'set/session_key'(state, data) {
		// 	console.log(data);
			
		// 	state.session_key = data;
		// 	uni.setStorageSync('session_key', data)
		// },
		login(state, data) {
			console.log(state);
			//console.log(data);
			state.hasLogin = true
			//state.uerInfo.token = data.token
			state.uerInfo.phone = data.phone
			state.uerInfo.cellphone = data.cellphone
			state.uerInfo.nickName = data.nickName
			state.uerInfo.avator = data.avator
			state.uerInfo.authIdentity = data.authIdentity  //实名
			state.uerInfo.authUser = data.authUser
			state.uerInfo.authUserEmp = data.authUserEmp
			uni.setStorage({
				key: 'uerInfo',
				data: data
			})		
			//console.log(data.phone+'99999999999999')
		},
		setToken(state, data) {
			uni.setStorage({
				key: 'token',
				data: data.token
			})
			//console.log(state.token+'121212222222222222222222')
		},
		
		
		logout(state) {
			state.hasLogin = false
			state.uerInfo = {}
			state.token = ''
			uni.removeStorage({
				key: 'uerInfo'
			});
			uni.removeStorage({
				key: 'token'
			});
			uni.removeStorage({
				key: 'nickName'
			});
			uni.removeStorage({
				key: 'avator'
			});
			// uni.removeStorage({
			// 	key: 'avatarUrl'
			// });
			// uni.removeStorage({
			// 	key: 'nickName'
			// });
			// uni.removeStorage({
			// 	key: 'authId'
			// });
		}
	},
	actions: {
	}
})

export default store
